# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgbase=pacman-bintrans
pkgname=('pacman-bintrans' 'pacman-bintrans-tools')
pkgver=0.4.0
pkgrel=1
pkgdesc='Binary transparency for pacman'
url='https://github.com/kpcyrd/pacman-bintrans'
arch=('loong64' 'x86_64')
license=('GPL3')
depends=('rekor' 'bzip2' 'openssl' 'shared-mime-info' 'zstd')
makedepends=('cargo')
source=(https://github.com/kpcyrd/${pkgbase}/archive/v${pkgver}/${pkgbase}-${pkgver}.tar.gz
        https://github.com/kpcyrd/${pkgbase}/releases/download/v${pkgver}/${pkgbase}-${pkgver}.tar.gz.asc)
sha512sums=('eb73b4fc4560dde54061fd243b754315a29dbad615345a24672599cf7e848edfb9224642820fb96ce31e1a4affe77f598f53741776b171bbd7a28573e01cfdd2'
            'SKIP')
b2sums=('36a5218ae689d93999d7c99ba93044d1bfd0bbc3b1ccd25026e01d46081acfa9b95d0ba783ea00c7593357814a46aba87dc7fac249dfe0cbdf4312fa3cd533d5'
        'SKIP')

validpgpkeys=("64B13F7117D6E07D661BBCE0FE763A64F5E54FD6")


prepare() {
  cd "${pkgbase}-${pkgver}"
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "${pkgbase}-${pkgver}"
  cargo build --frozen --release --workspace
}

check() {
  cd "${pkgbase}-${pkgver}"
  cargo test --frozen --workspace
}

package_pacman-bintrans() {
  cd "${pkgbase}-${pkgver}"
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/pacman-bintrans

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgbase}"
}

package_pacman-bintrans-tools() {
  pkgdesc='Binary transparency for pacman (sign/monitor tools)'
  depends=('shared-mime-info' 'rekor' 'openssl' 'sqlite' 'zstd')

  cd "${pkgbase}-${pkgver}"
  install -Dm 755 -t "${pkgdir}/usr/bin" \
    target/release/pacman-bintrans-sign \
    target/release/pacman-bintrans-monitor
}

# vim: ts=2 sw=2 et:
